package alibaba.common;

import java.io.IOException;

import alibaba.common.utils.Base64;

public class CheckEntry {

    private String filename;
    private int[] snapshotVersions;
    private byte[] signature;
    
    public CheckEntry(String filename, int[] snapshotVersions, byte[] signature) {
        this.filename = filename;
        this.snapshotVersions = snapshotVersions;
        this.signature = signature;
    }
    
    public String getFilename() {
        return filename;
    }
    public int[] getSnapshotVersions() {
        return snapshotVersions;
    }
    public byte[] getSignature() {
        return signature;
    }
    
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(filename);
        sb.append(", ");
        for (int snapshot : snapshotVersions) {
            sb.append(String.valueOf(snapshot));
            sb.append(" ");
        }
        sb.setLength(sb.length()-1);
        sb.append(", ");
        try {
            sb.append(Base64.encodeBytes(signature, Base64.URL_SAFE));
        } catch (IOException e) {
            sb.append("Failed encoding signature");
        }
        
        return sb.toString();
    }
    
}
